package dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Expression;
import org.springframework.stereotype.Repository;

import util.HibernateUtil;
import dao.DepartDao;
import entity.Depart;

@SuppressWarnings("deprecation")
@Repository
public class DepartDaoImpl implements DepartDao {
	@Resource
	private HibernateUtil util;

	@Override
	public boolean add(Depart dep) {
		return Integer.valueOf(util.save(dep).toString())>0;
	}
	@Override
	public boolean update(Depart dep) {
		return util.update(dep);
	}
	@Override
	public Depart get(int id) {
		return (Depart) util.get(Depart.class, id);
	}
	@Override
	public boolean del(int id) {
		return util.delete(Depart.class, id);
	}
	@Override
	public List<Depart> query() {
		return util.queryByHql("from Depart",true);
	}
	@Override
	public List<Depart> queryByPage(int page, int rows) {
		return util.queryHqlByPage("from Depart", true,page, rows);
	}
	@Override
	public int count() {
		return Integer.valueOf(util.getObjectByHql("select count(departid) from Depart").toString());
	}
	
}
